package com.fbinggun.fbinggunutil;



import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.KeybindComponent;
import org.bukkit.entity.Player;

import java.util.Collection;

/**
 * 玩家消息常用方法 Title消息 物品快捷栏上方小字消息
 */
@Deprecated
public class MessageUtil {



        //发送Title 并聊天栏返送消息

    /**
     * 发送 玩家集内所有玩家 Title消息
     * @param p 玩家集
     * @param title 标题
     * @param msg 小标题
     */
        public static void sendPlayerListTitleMsg(Collection<Player> p, String title,String msg){
            for(Player ps:p){
                sendTitleMsg(ps,title,msg);
            }
        }

    /**
     * 发送 Title消息 并发送聊天栏消息
     * @param p 玩家
     * @param title 大标题
     * @param msg 小标题
     */
    //发送Title 并聊天栏返送消息
    public static void sendTitleMsg(Player p, String title, String msg){
        title=title.replaceAll("&","§");
        msg=msg.replaceAll("&","§");
        if(PluginUtil.isPlaceholderAPI()){
            title = PApiUtil.setPlaceholders(p, title);
            msg = PApiUtil.setPlaceholders(p, msg);
        };
        p.sendTitle(title, msg, 20, 140, 20);
        p.sendMessage(msg);
    }


    /**
     * 发送屏幕小字 （物品栏上方小字)
     * @param player
     * @param msg
     */
    public static void sendActionBar(Player player,String msg){
        String ms = PApiUtil.setPlaceholders(player,msg);
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR,new KeybindComponent(ms));
    }
    public static void sendSYSTEMMsg(Player player,String msg){
        String ms = PApiUtil.setPlaceholders(player,msg);
        player.spigot().sendMessage(ChatMessageType.SYSTEM,new KeybindComponent(ms));
    }
    }
